<fieldset class="ui-widget">
    <legend class="ui-widget-header ui-corner-all">Shipper & Consignee</legend>
    <table class="ui-widget-content" style="width:100%;">
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('cus_id')); ?>
</th>
    <td><?php echo CHtml::encode($model->customer->cname); ?>
</td>
</tr>
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('con_id')); ?>
</th>
    <td><?php echo CHtml::encode($model->consignee->cname); ?>
</td>
</tr>
    </table>
</fieldset>
<fieldset class="ui-widget">
    <legend class="ui-widget-header ui-corner-all">Information</legend>
    <?php foreach($model->details() as $detail): ?>
    <table class="ui-widget-content" style="width:100%;">
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($detail->getAttributeLabel('ref_no')); ?>
</th>
<td colspan="3"><?php echo CHtml::encode($detail->ref_no); ?>
</td>
</tr>
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($detail->getAttributeLabel('qty')); ?>
</th>
    <td><?php echo CHtml::encode($detail->qty); ?>
</td>
<th class="label ui-widget-header">
    <?php echo CHtml::encode($detail->getAttributeLabel('wt')); ?>
</th>
<td>
    <?php echo CHtml::encode($detail->wt); ?>
</td>
</tr>
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($detail->getAttributeLabel('m3')); ?>
</th>
    <td><?php echo CHtml::encode($detail->m3); ?>
</td>
<th class="label ui-widget-header">
    <?php echo CHtml::encode($detail->getAttributeLabel('amt')); ?>
</th>
<td>
    <?php echo CHtml::encode($detail->amt); ?>
</td>
</tr>
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($detail->getAttributeLabel('in_date')); ?>
</th>
    <td><?php echo CHtml::encode((!empty($detail->in_date))?date('d/m/Y',$detail->in_date):''); ?>
</td>
<th class="label ui-widget-header">
    <?php echo CHtml::encode($detail->getAttributeLabel('out_date')); ?>
</th>
<td>
    <?php echo CHtml::encode($detail->out_date); ?>
</td>
</tr>
    </table>
    <?php endforeach; ?>
</fieldset>
<fieldset class="ui-widget" id="invoice_ref">
    <legend class="ui-widget-header ui-corner-all">Cargo document information</legend>
<?php
    $invoices = array();
    if(count($model->invoices)>0):
        foreach($model->invoices() as $invoice) {
            $invoices[$invoice['ref_type']]['ref'] = (empty($invoices[$invoice->ref_type]['ref']))?$invoice->ref_no:trim($invoices[$invoice->ref_type]['ref']).', '.$invoice->ref_no;
            //$invoices[$invoice->ref_type]['amt'] += (!isset($invoices[$invoice->ref_type]['amt']))?0:1;
        }
?>
<table class="ui-widget-content" style="width:100%;">
    <?php foreach($invoices as $key=>$item): ?>
        
<tr>
    <th class="label ui-widget-header"><?php echo CHtml::encode(invoice::model()->getRefType($key));//."<sup>({$item['amt']})</sup>"; ?>
</th>
    <td><?php echo CHtml::encode($item['ref']); ?>
</td>
</tr>
<?php endforeach;?>
    </table>
<?php else: ?>
    <h5>No reference No. being registered.</h5>
<?php endif; ?>
</fieldset>
<fieldset class="ui-widget">
    <legend class="ui-widget-header ui-corner-all">Remarks</legend>
    <?php if(!empty($model->desc)): ?>
    <table class="ui-widget-content" style="width:100%;">
<tr>
	<th class="label ui-widget-header"><?php echo CHtml::encode($model->getAttributeLabel('desc')); ?>
</th>
    <td><?php echo CHtml::encode($model->desc); ?>
</td>
    </table>
    <?php else: ?>
    <h5>No remarks for this shipment is being registered</h5>
    <?php endif; ?>
</fieldset>